package crawlers;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class WebpagetestBreakdown {
	
	private Document doc = null;
	
	private String url = "http://www.webpagetest.org/result/";
	
	public WebpagetestBreakdown(String id) {
		try {
			//Goto homepage
			String urlResult = url + id + "/1/breakdown/";
			doc = Jsoup.connect(urlResult).get();
			
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
	
	
	public String getContentBreakDown() {
		String script = doc.select("script").last().html();
		
		return script;
	}
	
	public String getConnectionView(String id) {
		String img = "http://www.webpagetest.org/waterfall.png?width=930&type=connection&test="+ id +"&run=1&mime=1&cached=0";
		
		return img;
	}
	
	public String getConnectionViewRv(String id) {
		String img = "http://www.webpagetest.org/waterfall.png?width=930&type=connection&test="+ id +"&run=1&mime=1&cached=1";
		
		return img;
	}
	
	
}
